CUR     := $(CURDIR)
BUILD   := $(CUR)/build
INCLUDE := $(CUR)/include
LIB     := $(CUR)/lib
SRC     := $(CUR)/src
CFLAGS  := -I$(INCLUDE) -Wall -Wextra -O2 -fPIC
OBJECTS := symstr.o hashmap.o speed.o

.PHONY: all

all: clean build

clean:
	@$(if $(wildcard $(BUILD)), rm -rf $(BUILD)/*, mkdir $(BUILD))
	@$(if $(wildcard $(LIB)), rm -rf $(LIB)/*, mkdir $(LIB))
	@echo "Cleaned"

build: $(OBJECTS)
	@$(AR) -rcs $(LIB)/libsym.a $(addprefix $(BUILD)/, $(OBJECTS))
	@echo "Built"

%.o: $(SRC)/%.c
	@$(CC) $(CFLAGS) -c $< -o $(BUILD)/$@